<template>
	<view>
		<image src="/static/work1.jpg" mode="" class="img_bg"></image>
		<view class="" style="position: absolute; top: 0; width: 100%; border-radius: 2%;">
			<view class="border-bottom bg_white margin-t30 margin-l10 margin-r10">
				<view class="display justify-between align-center">
					<view class="text-36 padding-t30 padding-b30">整改照片</view>
					<view class="text-24 font-gray">图片大小限制500K,请勿上传无关内容。</view>
				</view>
				<view class="display align-center padding-b30" @tap="upAdd()">
					<image :src="phone" class="addImage padding-r10" v-if="phone!=''"></image>
					<image src="/static/add.png" class="addImage"></image>
				</view>
			</view>
			<view class="border-bottom display justify-between align-center bg_white margin-l10 margin-r10">
				<view class="text-36 padding-t30 padding-b30">整改人</view>
				<view class="text-32 font-gray1 padding-r30">{{rectify_user?rectify_user:'-'}}</view>
			</view>
			<view class="border-bottom bg_white margin-l10 margin-r10">
				<view class="text-36 padding-t30 padding-b30">整改措施描述</view>
				<view class="display align-center">
					<textarea placeholder="请输入描述信息..." name="content" v-model="content" placeholder-style="color:#999;font-size:28upx;" />
					</view>
			</view>
			<view class="margin-l10 margin-r10" >
					<button  @click="sign()" class="loginButton margin-t30" :disabled= "disable_check">提交</button>
				</view>
				</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uid:'',
				token:'',
				rectify_remarks:'',//整改备注
				rectify_img:'',//整改图片
				sird_id:'',
				id:'',
				nickname:'',
				rectify_user:'',
				phone:'',
				content:'',
				disable_check:false
			}
		},
		onLoad(options){
			this.nickname=uni.getStorageSync('user').nickname
			this.uid =uni.getStorageSync('user').uid;
			this.token =uni.getStorageSync('user').token;
			console.log(options)
			this.sird_id=options.sird_id
			this.id=options.id
			this.rectify_user=options.rectify_user
			console.log(this.sird_id)
			console.log(this.id)
			console.log(this.rectify_user)
			this.ckeck()
		},
		methods: {
			upAdd(){
				let that = this
				uni.chooseImage({
					count:1,
					sizeType:['compressed'],
					sourceType:['camera','album'],
					success:res => {
						// console.log(JSON.stringify(res.tempFilePaths));
						const tempFilePaths=res.tempFilePaths;
						uni.uploadFile({
							url:'https://aqmore.sxpz.vip/AppApi/Public/uploadImg?c=uperTest',
							filePath: tempFilePaths[0],
							name: 'file',
							formData: {'user': 'test'},
							success: uploadFileRes => {
								
								that.phone=(uploadFileRes.data)
							}
						})
					},
				})
			},
			ckeck(){
				if(this.nickname!=this.rectify_user){
					this.disable_check=true
				}
			},
			async sign(){
				this.disable_check=true
				var that=this;
				if(this.phone==''){
					uni.showToast({
						title:'请上传整改照片',
						icon:'none'
					})
					this.disable_check=false
					return false
				}else if(this.content==''){
					uni.showToast({
						title:'请填写整改措施',
						icon:'none'
					})
					this.disable_check=false
					return false
				}
				
				const {
					data: res
				} = await this.$myRequest({
					url: '/Convenient/setRectification',
					method: 'GET',
					data: {
						uid: this.uid,
						token: this.token,
						id: this.id,
						sird_id: this.sird_id,
						rectify_remarks:this.content,
						rectify_img:this.phone
					}
				});
				console.log(res)
				uni.showToast({
					title: res.datas.msg,
					icon: 'none'
				})
				setTimeout(() => {
					uni.switchTab({
						url: '../../workspace'
					})
				}, 1500)
				
				/* uni.request({
					url:'https://aqmore.sxpz.vip/AppApi/Convenient/setRectification?uid='+this.uid+'&token='+this.token+'&id='+this.id+'&sird_id='+this.sird_id+'&rectify_remarks='+this.content+'&rectify_img='+this.phone,
					method:'GET',
					header:{'content-type':'application/x-www-form-urlencoded'},
					success:function(e){
						console.log(e)
						that.disable_check=true
						uni.showToast({
							title:e.data.datas.msg,
							icon:'success'
						})
						setTimeout(()=>{
						uni.switchTab({
							url:'../../workspace'
						})
						},1500)
					},
					
				}) */
				
			}
				
			
		}
	}
</script>

<style>
.loginButton{
		height:98upx;
		line-height: 98upx;
		background:#65caff;
		box-shadow:0 2upx 10upx 0 rgba(115, 241, 255, 0.8);
		border-radius:49upx;
		color: #fff;
		text-align: center;
		z-index: 99;
		position: relative;
	}
</style>
